package cn.wendellup.bootStrap.valueobject.entity;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

public class AdvPosition implements Serializable, RowMapper<AdvPosition> {

    private static final long serialVersionUID = 1L;

    public static class FieldStatus {
        public static int typeId = 1;
        public static int name = 2;
        public static int width = 4;
        public static int height = 8;
        public static int price = 16;
        public static int enable = 32;
        public static int description = 64;
        public static int avdCount = 128;
    }

    private int id;
    private int typeId;
    private String name;
    private int width;
    private int height;
    private int price;
    private int enable;
    private String description;
    private int avdCount;

    private int updateStatus = 0;
    public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}

	public int getTypeId() {
        return typeId;
    }

    public void setTypeId(int typeId) {
        if (this.typeId != typeId) {
            this.typeId = typeId;
            this.updateStatus = this.updateStatus | AdvPosition.FieldStatus.typeId;
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if (this.name != name) {
            this.name = name;
            this.updateStatus = this.updateStatus | AdvPosition.FieldStatus.name;
        }
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        if (this.width != width) {
            this.width = width;
            this.updateStatus = this.updateStatus | AdvPosition.FieldStatus.width;
        }
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        if (this.height != height) {
            this.height = height;
            this.updateStatus = this.updateStatus | AdvPosition.FieldStatus.height;
        }
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        if (this.price != price) {
            this.price = price;
            this.updateStatus = this.updateStatus | AdvPosition.FieldStatus.price;
        }
    }

    public int getEnable() {
        return enable;
    }

    public void setEnable(int enable) {
        if (this.enable != enable) {
            this.enable = enable;
            this.updateStatus = this.updateStatus | AdvPosition.FieldStatus.enable;
        }
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        if (this.description != description) {
            this.description = description;
            this.updateStatus = this.updateStatus | AdvPosition.FieldStatus.description;
        }
    }

    public static long getSerialversionuid() {
        return serialVersionUID;
    }

    public int getAvdCount() {
        return avdCount;
    }

    public void setAvdCount(int avdCount) {
        if (this.avdCount != avdCount) {
            this.avdCount = avdCount;
            this.updateStatus = this.updateStatus | AdvPosition.FieldStatus.avdCount;
        }
    }

    public int getUpdateStatus() {
        return updateStatus;
    }

    public void setUpdateStatus(int updateStatus) {
        this.updateStatus = updateStatus;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("AdvPosition [id=");
        builder.append(id);
        builder.append(", typeId=");
        builder.append(typeId);
        builder.append(", name=");
        builder.append(name);
        builder.append(", width=");
        builder.append(width);
        builder.append(", height=");
        builder.append(height);
        builder.append(", price=");
        builder.append(price);
        builder.append(", enable=");
        builder.append(enable);
        builder.append(", description=");
        builder.append(description);
        builder.append(", avdCount=");
        builder.append(avdCount);
        builder.append(", updateStatus=");
        builder.append(updateStatus);
        builder.append("]");
        return builder.toString();
    }

	@Override
	public AdvPosition mapRow(ResultSet rs, int arg1) throws SQLException {
		AdvPosition entity = new AdvPosition();
		entity.setId(rs.getInt("id"));
		entity.setTypeId(rs.getInt("type_id"));
		entity.setName(rs.getString("name"));
		entity.setWidth(rs.getInt("width"));
		entity.setHeight(rs.getInt("height"));
		entity.setPrice(rs.getInt("price"));
		entity.setEnable(rs.getInt("enable"));
		entity.setDescription(rs.getString("description"));
		entity.setAvdCount(rs.getInt("adv_count"));
		return entity;
	}

}
